/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package com.blog.city.checkthedep.managedbeans;

import com.blog.city.checkthedep.entities.RegisteredUser;
import com.blog.city.checkthedep.sessionbeans.RegisteredUserFacadeLocal;
import javax.ejb.EJB;
import javax.faces.application.FacesMessage;
import javax.faces.bean.ManagedBean;
import javax.faces.bean.RequestScoped;
import javax.faces.context.FacesContext;

/**
 *
 * @author Breath
 */
@ManagedBean
@RequestScoped
public class RegistrationBean {

    private RegisteredUser registeredUser = new RegisteredUser();
    @EJB
    private RegisteredUserFacadeLocal registeredFacade;

    /**
     * 
     * @return
     */
    public RegisteredUser getRegisteredUser() {
        return registeredUser;
    }

    /**
     * 
     * @param registeredUser
     */
    public void setRegisteredUser(RegisteredUser registeredUser) {
        this.registeredUser = registeredUser;
    }

    /**
     * 
     * @return
     */
    public RegisteredUserFacadeLocal getRegisteredFacade() {
        return registeredFacade;
    }

    /**
     * 
     * @param registeredFacade
     */
    public void setRegisteredFacade(RegisteredUserFacadeLocal registeredFacade) {
        this.registeredFacade = registeredFacade;
    }

    /**
     * 
     */
    public void persistRegisteredUser() {
        if (registeredUser != null) {
            registeredFacade.create(registeredUser);
        }
        FacesContext.getCurrentInstance().addMessage(null, 
                    new FacesMessage(FacesMessage.SEVERITY_INFO, 
                    "Member was created succesfully", "Member Created"));
    }
}
